<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css"  media="all">
</head>
<body>
    <select id="aa">
        <option th:each="item:${data}" th:value="${item.id}" >[[${item.title}]]</option>
    </select>
    <div id="test1" class="demo-tree demo-tree-box"></div>

</body>
<script src="/jquery-3.4.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script>
   $("#aa").change(function(){
       $.ajax({
           url:"/resources/selectTree",
           data:{"id":$("#aa option:selected").val()},
           type:"get",
           success:function(data){
               console.log(data);
               layui.use(['tree', 'util'], function(){
                   var tree = layui.tree,
                       layer = layui.layer,
                       util = layui.util
                   tree.render({
                       elem: '#test1' //默认是点击节点可进行收缩
                       ,data: data
                   });
               });
           }
       });
   });

</script>
</html>